package com.wanmei.service.Impl;

import com.wanmei.mapper.ProductpicMapper;
import com.wanmei.pojo.Product;
import com.wanmei.pojo.Productpic;
import com.wanmei.service.ProductpicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductpicServiceImpl implements ProductpicService {
    @Autowired
    private ProductpicMapper productpicMapper;

    /**
     * 返回商品图片列表
     *
     * @return
     */
    @Override
    public List<Product> findProductPicList() {
        return productpicMapper.findProductPicList();
    }

    /**
     * 通过pid来获取第一张图片
     *
     * @param pid
     * @return
     */
    public Productpic selectOnePicUrl(int pid) {
        return productpicMapper.selectOnePicUrl(pid);
    }
    public Productpic selectAllByPicId(int picid){
        return productpicMapper.selectByPrimaryKey(picid);
    }

    @Override
    public Product selectByPID(Integer pid) {
        return productpicMapper.selectByPID(pid);
    }

    @Override
    public int deleteByPrimaryKey(Integer picid) {
        return productpicMapper.deleteByPrimaryKey(picid);
    }
  public int addProductPic(Productpic productpic){
        return productpicMapper.insertSelective(productpic);
  }

}
